@import '@automattic/typography/styles/variables';
@import '@wordpress/base-styles/mixins';
@import '@wordpress/base-styles/variables';
@import 'calypso/assets/stylesheets/shared/mixins/breakpoints';

/**
 * Styling for '/post' route.
 */
.help-center-article {
	padding: 0;

	> * {
		box-sizing: border-box;
	}

	.help-center-article__header {
		a.help-center-article__external-button {
			padding: 8px;
		}
	}

	.help-center-article-content {
		padding: 16px;
		display: flex;
		flex-direction: column;

		.help-center-article-content__header {
			.help-center-article-content__header-link {
				@include body-medium;
				color: var(--studio-gray-60);
				margin: 8px 0;
				display: block;
				text-decoration: none;

				svg.gridicons-external {
					top: 3px;
				}
			}

			h1.help-center-article-content__header-title {
				font-size: 1.75rem;
				font-weight: 600;
				line-height: 1.2;
			}
		}

		.help-center-article-content__main {
			h2,
			h3,
			h4,
			h5 {
				font-weight: 600;
				color: var( --color-neutral-100 );
				margin: 8px 0;
			}

			button.button.is-borderless:focus,
			a.button.is-borderless:focus {
				color: #043959;
				box-shadow:
					0 0 0 1px #4f94d4,
					0 0 2px 1px rgba( 79, 148, 212, 0.8 );
				outline: 1px solid transparent;
				border-color: inherit;
			}

			a[name='toc'] span {
				color: var( --color-neutral-80 );
				font-size: $font-body;
			}

			p.toc-jump {
				display: none;
			}

			.clipboard-button {
				display: none;
			}

			.wp-block-a8c-support-table-of-contents {
				background-color: var( --studio-blue-5 );
				padding: 16px;

				ol {
					list-style-type: none;
					margin: 0;
				}

				li {
					margin-bottom: 0;

					a {
						font-size: $font-size-large;
						line-height: 1.6;
						text-decoration: none;
					}

					ol {
						margin-left: 1em;
					}
				}
			}

			p {
				font-size: $font-size-large;
				line-height: 1.6;
				color: var( --color-neutral-80 );
			}

			ul,
			ol.wp-block-list {
				font-size: $font-body-small;
				color: var( --color-neutral-80 );
				list-style-position: outside;
				margin: 0 0 1.5em 1.5em;

				ul,
				li {
					margin-bottom: 0;
				}
			}

			ul {
				list-style-type: circle;
			}

			span.noticon.noticon-star {
				color: var( --studio-yellow-20 );
			}

			.help-center-article-content__header {
				margin-bottom: 0;
			}

			.wp-block-quote {
				background-color: var( --color-neutral-0 );
				border-left: none;
				padding: 16px;
				color: var( --color-neutral-80 );
			}

			.wp-block-separator {
				margin: auto;
				border-bottom: 1px solid var( --color-neutral-10 );
				border-top: 0;
				width: 100%;
			}

			.wp-block-group__inner-container {
				background-color: var( --color-neutral-0 );
				padding: 16px 0;
			}

			:where( .wp-block-group.has-background ) {
				padding: 0;
			}

			.has-background {
				padding: 16px;

				&.has-gray-theme-background-color {
					background-color: var( --studio-gray-0 );
				}
			}

			.wp-block-button {
				width: 100%;

				.wp-block-button__link {
					background-color: var( --color-surface );
					border: 1px solid var( --color-neutral-10 );
					border-radius: 2px;
					box-sizing: border-box;
					color: var( --color-neutral-70 );
					display: inline-block;
					font-size: $font-body-small;
					padding: 8px 14px;
					text-align: center;
					text-decoration: none;
					width: 100%;
				}
			}

			.button-primary {
				background-color: var( --wp-admin-theme-color );
				border: 1px solid var( --wp-admin-theme-color );
				border-radius: 2px;
				color: var( --color-text-inverted );
				font-size: $font-body-small;
				padding: 4px 14px;
				width: 100%;
			}

			.callout .wp-block-column {
				$callout-border: #dcdcde;
				$callout-background: #fff;
				$callout-large-font-size: 40px;

				padding: 0.5em;
				border-radius: 4px;
				border: 1px solid $callout-border;
				background: $callout-background;

				.wp-block-quote {
					margin: 0;
					background: $callout-background;
				}

				.has-text-align-center {
					text-align: center;
				}

				.has-large-font-size {
					font-size: $callout-large-font-size;
					line-height: 48px;
				}

				.is-vertically-aligned-center {
					align-self: center;
				}

				.wp-block-jetpack-layout-grid {
					display: grid;
					grid-template-columns: repeat( 4, 1fr );

					&.wp-block-jetpack-layout-gutter__none {
						grid-gap: 0;
					}

					&.column1-tablet-grid__row-1 > .wp-block-jetpack-layout-grid-column:nth-child( 1 ) {
						grid-row-start: 1;
					}

					&.column2-desktop-grid__start-2 > .wp-block-jetpack-layout-grid-column:nth-child( 2 ) {
						grid-column-start: 2;
						grid-column-end: span 4;
					}
				}
			}

			.wp-block-image figure figcaption {
				display: block;
			}

			color: var( --color-neutral-70 );
			font-size: $font-body;
			line-height: 1.7;
			margin: 0;
			padding-top: 16px;
			position: relative;
			overflow-wrap: break-word;
			word-wrap: break-word;

			// Temporary fix on the help center article content inside the editor
			.wp-block-columns-is-layout-flex {
				display: block !important;
			}

			.wp-block-heading {
				scroll-margin-top: 15px;
				line-height: 1.4;
				margin: 1.5rem 0 0.25rem;
			}

			h1 {
				font-size: $font-title-large;
				font-weight: 600;
				margin: 0 0 16px;
			}

			h2 {
				font-size: rem( 20px );
			}

			h3 {
				font-size: rem( 15px );
				font-weight: 600;
				margin: 0 0 8px;
			}

			h4 {
				font-size: rem( 13px );
				font-weight: 600;
				margin: 0 0 8px;
			}

			h5 {
				font-size: rem( 11px );
			}

			p,
			> div {
				margin: 0 0 1em;

				&:last-child {
					margin-bottom: 0;
				}
			}

			blockquote {
				padding: 0 24px 0 32px;
				margin: 16px 0 32px;
				border-left: 3px solid var( --color-neutral-0 );
				color: var( --color-neutral-50 );
				font-weight: 400;
				background: transparent;
			}

			hr {
				background: var( --color-neutral-0 );
				margin: 24px 0;
			}

			img {
				max-width: 100%;
				height: auto;
				display: inline;
				margin: auto;
				margin-bottom: 12px;
			}

			figure img {
				display: inherit;
				margin-bottom: 0;
			}

			audio {
				display: block;
				width: 100%;
				margin: 24px auto;
			}

			iframe[class^='twitter-'],
			iframe[class^='instagram-'],
			.fb_iframe_widget {
				display: block;
				margin: 24px auto !important;
			}

			@include breakpoint-deprecated( '>660px' ) {
				.alignleft {
					max-width: 100%;
					float: left;
					margin-top: 12px;
					margin-bottom: 12px;
					margin-right: 32px;
				}

				.alignright {
					max-width: 100%;
					float: right;
					margin-top: 12px;
					margin-bottom: 12px;
					margin-left: 32px;
					display: block !important;
				}
			}

			@include breakpoint-deprecated( '<660px' ) {
				.alignleft,
				.alignright {
					clear: both;
					margin-top: 24px;
					margin-bottom: 24px;
				}
			}

			.aligncenter {
				clear: both;
				display: block;
				margin-top: 24px;
				margin-bottom: 24px;
			}

			.wp-caption.alignnone {
				clear: both;
				display: block;
				margin-top: 24px;
				margin-bottom: 24px;
			}

			.wp-caption {
				position: relative;
				max-width: 100%;

				&.alignright {
					float: right;
				}

				&.alignleft {
					float: left;
				}

				&.alignright,
				&.alignleft {
					max-width: 100%;

					@include breakpoint-deprecated( '>660px' ) {
						max-width: 50%;
					}

					img.alignright,
					img.alignleft {
						float: none;
					}
				}

				img {
					display: block;
					margin: 0 auto;
				}
			}

			.wp-caption-text,
			figure figcaption,
			figure .caption,
			.wp-caption .wp-media-credit {
				padding: 12px;
				margin: 0;
				font-size: $font-body-small;
				text-align: center;
				color: var( --color-neutral-40 );
				display: block !important;
			}

			// placeholder for videopress videos
			.video-plh-notice {
				position: relative;
				margin-bottom: 24px;
				padding: 11px 24px;
				border-radius: 2px;
				background: var( --color-neutral-0 );
				box-sizing: border-box;
				font-size: $font-body-small;
				line-height: 1.4285;
				animation: appear 0.3s ease-in-out;

				@include breakpoint-deprecated( '>660px' ) {
					padding: 13px 48px;
					font-size: inherit;
				}
			}

			sup,
			sub {
				vertical-align: baseline;
				position: relative;
				font-size: $font-body-extra-small;
			}

			sup {
				top: -0.4em;
			}

			sub {
				bottom: -0.2em;
			}

			table th,
			table td {
				padding: 10px;
			}

			img:first-child {
				margin-top: 0;
			}

			.a8c-table-of-contents {
				& > p,
				& > button {
					display: none;
				}

				ol.toc-parent-list {
					padding-left: 0;
				}

				.after-toc {
					display: none;
				}
			}

			.wp-block-embed__wrapper {
				position: relative;

				&::before {
					content: '';
					display: block;
					padding-top: 56.25%;
				}

				iframe {
					bottom: 0;
					height: 100%;
					left: 0;
					position: absolute;
					right: 0;
					top: 0;
					width: 100%;
				}
			}

			.wp-block-wpsupport3-update-plan-cta {
				.container .card {
					margin-top: 16px;

					.small {
						font-size: $font-body-extra-small;
					}

					.title {
						font-size: $font-title-small;
					}
				}

				.plan-options {
					display: none;
				}
			}

			// Show the tab component for the WP Support 3 tab component
			.wp-block-wpsupport3-tabs {
				.aligncenter {
					margin-left: auto;
					margin-right: auto;
				}

				.wpsupport3-tab__tablist {
					display: flex;
					align-items: center;
					gap: 24px;
					white-space: nowrap;
					overflow-x: auto;
					border-bottom: 1px solid var( --wp--preset--color--border-light-gray, #eee );

					.wpsupport3-tab__title {
						padding: 8px 0;

						color: var( --blue-blue-50, #0675c4 );
						font-size: $font-body;
						line-height: 24px;
						border: none;
						background: none;
						border-bottom: 1px solid transparent;
						transition: border-bottom 0.3s;

						&:focus {
							outline: none;
						}

						&:hover {
							text-decoration: none;
						}

						&[aria-selected='true'] {
							color: var( --gray-gray-100, #101517 );
							border-bottom: 1px solid var( --gray-gray-100, #101517 );
						}
					}
				}
			}

			.wp-block-wpsupport3-tab {
				margin-top: 32px;
				display: none;

				&:not( [aria-hidden='true'] ) {
					display: block;
					animation: fadeIn 0.5s;
				}

				@keyframes fadeIn {
					from {
						opacity: 0;
					}

					to {
						opacity: 1;
					}
				}
			}

			.wp-block-newspack-blocks-homepage-articles {
				.entry-wrapper {
					.entry-title {
						a {
							text-decoration: underline;
						}
					}
				}
			}

			// External link icon styles
			.help-center-external-link-icon {
				color: currentColor;
				fill: currentColor;
				position: relative;
				vertical-align: sub;
			}

			// Screen reader text for accessibility
			.screen-reader-text {
				clip: rect( 1px, 1px, 1px, 1px );
				position: absolute !important;
				height: 1px;
				width: 1px;
				overflow: hidden;
			}
		}
	}

	.help-center-article__error {
		padding: 16px 30px 20px;
		font-size: 0.875rem;
		color: var( --color-neutral-80 );
	}
}
